﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Xml;
using com.lover.astd.common.config;
using com.lover.astd.common.model;
using com.lover.astd.common;

namespace com.lover.astd.game.ui.server.impl.equipment
{
    public class StoreServer : LogicServer
    {
        public StoreServer(MainForm frm) { _mainForm = frm; ServerName = ConfigStrings.S_Store; ServerReadableName = ConfigStrings.SR_Store; }
        public override void renderSettings()
        {
            MainForm frm = _mainForm;
            Dictionary<string, string> conf = getConfig(ServerName);
            frm.chk_upgrade_gem.Checked = conf.ContainsKey(ConfigStrings.enabled) && conf[ConfigStrings.enabled].ToLower().Equals("true");
            if (conf.ContainsKey(ConfigStrings.merge_gem_level))
            {
                int merge_gem_level = 0;
                Int32.TryParse(conf[ConfigStrings.merge_gem_level], out merge_gem_level);
                frm.num_upgrade_gem.Value = merge_gem_level;
            }
        }
        public override void saveSettings()
        {
            MainForm frm = _mainForm;
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, frm.chk_upgrade_gem.Checked.ToString());
            conf.setConfig(ServerName, ConfigStrings.merge_gem_level, frm.num_upgrade_gem.Value.ToString());
        }
        public override void loadDefaultSettings()
        {
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, "true");
            conf.setConfig(ServerName, ConfigStrings.merge_gem_level, "12");
            renderSettings();
        }
    }
}
